#if !defined(__APP_SERIAL_H)
#define __APP_SERIAL_H

#define _GNU_SOURCE
#include <termio.h>
#include "app_device.h"

//波特率枚举
typedef enum{
    BAUDRATE_9600 = B9600,
    BAUDRATE_115200 = B115200,
}BaudRate;

//校验位枚举
typedef enum{
    PARITY_NONE = 0,
    PARITY_ODD = PARENB | PARODD,
    PARITY_EVEN = PARENB,
}Parity;

//停止位枚举
typedef enum{
    STOPBIT_1 = 0,
    STOPBIT_2 = CSTOPB,
}StopBit;

//初始化
int app_serial_init(device_t *dev);
//设置波特率
int app_serial_set_baudrate(device_t *dev, BaudRate baudrate);
//设置校验位
int app_serial_set_parity(device_t *dev, Parity parity);
//设置停止位
int app_serial_set_stopbit(device_t *dev, StopBit stopbit);
//设置是否阻塞模式
int app_serial_set_block(device_t *dev, int is_block);
//设置为原始模式
int app_serial_set_raw(device_t *dev);

//flush串口数据
int app_serial_tclflush(device_t *dev);
#endif // __APP_SERIAL_H
